﻿@using ThuySan.Areas.Backend.Models
@model IEnumerable<dynamic>
@{
    Layout = "~/Areas/Backend/Views/Shared/_Layout.cshtml";

    Header header = new Header {
                                       Common = "ViewUserControl_Tag_Index",
                                       CurentCommon = "Tag",
                                       PageHeader = "Manage Tag",
                                       Menulv1 = "01",
                                       Menulv2 = "0104"
                               };
    ViewData[Header.Key] = header;
    ViewBag.Title = "Manage Tag - Admin Control Panel";

}
@(Html.Telerik().Grid(Model).Name("grid").Columns(c =>
                                                      {
                                                          c.Bound(typeof (int), "TagId").Title("#").Width(50);
                                                          c.Bound(typeof (string), "Name");
                                                          c.Bound(typeof (string), "GroupName");
                                                          c.Bound("IsStaticContent").Filterable(false).ClientTemplate("<input <#= IsTopMenu #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsTopMenu").Filterable(false).ClientTemplate("<input <#= IsTopMenu #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsLeftColumn").Filterable(false).ClientTemplate("<input <#= IsLeftColumn #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsRightColumn").Filterable(false).ClientTemplate("<input <#= IsRightColumn #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Bound("IsFooter").Filterable(false).ClientTemplate("<input <#= IsFooter #> class=\"check-box\" disabled=\"disabled\" type=\"checkbox\" />");
                                                          c.Template(v => v.ProductId).ClientTemplate(Html.ActionLink("<span class=\"t-icon t-edit\"></span>", "Edit", new {
                                                                                                                                                                                   id = "<#=TagId#>"
                                                                                                                                                                           }, new {
                                                                                                                                                                                          @class = "t-button t-button-icon t-grid-edit",
                                                                                                                                                                                  }).ToHtmlString() + "<a class=\"t-button t-button-icon t-grid-delete\" href=\"javascript:Delete(<#=TagId#>);\"><span class=\"t-icon t-delete\"></span></a>").Width(80);
                                                      }).Sortable(c => c.Enabled(true)).Filterable().DataKeys(c => c.Add("TagId")).Pageable(c =>
                                                                                                                                                {
                                                                                                                                                    c.Enabled(true);
                                                                                                                                                    c.PageSize(25);
                                                                                                                                                }).DataBinding(c => c.Ajax().Select("GetList", "Tag")))
@section script
{
    <script type="text/javascript">
        function Delete(id) {
            if (confirm("Do you want to delete?"))
                $.post('@Url.Action("Delete", "Tag")', { id: id }, function(data) {
                    ShowNotification(data);
                    $("#grid").data("tGrid").ajaxRequest();
                });
        }
    </script>
}